package com.cw.wh.base;

/**
 * 返回类型
 */

public class R {

    /**
     * 返回标识  0 代表正常  其他代表错误  具体见错误码
     */
    private int code;
    /**
     * 数据
     */
    private Object data;
    /**
     * 描述
     */
    private String message;

    public R(int code, Object data, String message) {
        this.code = code;
        this.data = data;
        this.message = message;
    }

    public static R ok(){
        return new R(Rcode.SUCCESS.getCode() , null , Rcode.SUCCESS.getMessage());
    }

    public static R ok(Object data){
        return new R(Rcode.SUCCESS.getCode() , data , Rcode.SUCCESS.getMessage());
    }

    public static R error(Rcode rcode){
        return new R(rcode.getCode() , null , rcode.getMessage());
    }

    public static R error(Integer code , String message){
        return new R(code , null , message);
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }
}
